#{extends 'adminm/frame.html' /}

#{set 'moreScripts'}
<script src="@{'/public/javascripts/jquery-ui-1.8.10.custom.min.js'}" type="text/javascript" charset="utf-8"></script>
#{/set}
#{set 'moreStyles'}
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/table.scss'}" />
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/commodity.scss'}" />
#{/set}
#{set 'activeItem'}3#{/set}
<script language="javascript">
$(function(){
	resetOnSaleStatus()
});
function resetOnSaleStatus() {
	var onSaleStatus = $("#onSaleStatus").val();
	var changeQuantityWayDiv = $("#changeQuantityWayDiv");
	if("ONSALE_LIMITED" != onSaleStatus) {
		$(changeQuantityWayDiv).css("display", "none");
		//quantityLeft.style.display = "none";
	} else {
		$(changeQuantityWayDiv).css("display", "inline");
		//quantityLeft.style.display = "inline";
	}
}
function reSetData() {
	window.location.href="/admin/commodities/${commodity.id};editQuantity";
}

function goBack() {
	window.location.href="/admin/commodities;admin";
}
</script>
<div class="navigationBar">
	<table>
		<tr>
			<td><img src="@{'/public/images/navigationHouse.gif'}"></td>
			<td><strong>当前位置：</strong></td>
			<td>
				<a href="/admin">首页</a>
				>>
				<a href="#">商品管理</a>
				>>
				<a href="/admin/brand/index">品牌管理</a>
				>>
				<font class="current">库存编辑</font>
			</td>
		</tr>
	</table>
	#{form @admin.Commodities.updateQuantity(), id:'new-form'}
	<fieldset>
		<div id="commodity-image">
			#{if commodity.image}
				<img id="image" src="@{Attachments.show(commodity.image.id)}"/>
			#{/if}
			#{else}
				<img id="image" src="@{'/public/images/image-placeholder.png'}"/>
			#{/else}
		</div>
		<p>
			#{field 'commodity.id'}
			<label>商品&nbsp;&nbsp;ID:</label>
			<input type="text" value="${commodity?.id}" disabled class="${field.errorClass}" />
       		<input type="hidden" name="commodity.id" value="${commodity?.id}" />
       		#{/field}
		</p>
		<p>
			#{field 'commodity.name'}
	        <label>商品名称:</label>
	        <input type="text" name="${field.name}"  disabled
	            value="${commodity?.name}" class="${field.errorClass}" />
			<span class="error">#{error 'commodity.name' /}</span>
	        #{/field}
		</p>
		<p>
			#{field 'commodity.quantityLeft'}
	        <label>当前货存:</label>
	        <input type="text" name="${field.name}"  disabled
	            value="${commodity?.quantityLeft}" class="${field.errorClass}" />
			<span class="error">#{error 'commodity.quantityLeft' /}</span>
	        #{/field}
		</p>
		<p>
    		<label>货存类型:</label>
        	#{field 'commodity.onSaleStatus'}
        	<select id="onSaleStatus" name="commodity.onSaleStatus" onChange="resetOnSaleStatus()">
        		<option value="ONSALE_LIMITED" #{if commodity.onSaleStatus == models.Commodity.OnSaleStatus.ONSALE_LIMITED}selected#{/if}>有货</option>
        		<option value="ONSALE_UNLIMITED" #{if commodity.onSaleStatus == models.Commodity.OnSaleStatus.ONSALE_UNLIMITED}selected#{/if}>长期有货</option>
        		<option value="OFFSALE" #{if commodity.onSaleStatus == models.Commodity.OnSaleStatus.OFFSALE}selected#{/if}>商品下架</option>
        	</select>
        	<span class="important_1_1">*</span>&nbsp;
        	<span class="error">#{error 'commodity.onSaleStatus' /}</span>
        	#{/field}
    	</p>
    	<br>
    	<p id="changeQuantityWayDiv">
    		<label>修改方式:</label>
        	#{field 'changeQuantityWay'}
        	<select id="changeQuantityWay" name="changeQuantityWay">
        		<option value="SET_TO" #{if changeQuantityWay == models.Commodity.ChangeQuantityWay.SET_TO}selected#{/if}>设置为</option>
        		<option value="ADD" #{if changeQuantityWay == models.Commodity.ChangeQuantityWay.ADD}selected#{/if}>增加</option>
        		<option value="MINUS" #{if changeQuantityWay == models.Commodity.ChangeQuantityWay.MINUS}selected#{/if}>减少</option>
        	</select>
        	<input type="text" id="quantityLeft" name="quantityLeft" value="0" maxlength="10">
        	<span class="important_1_1">*</span>&nbsp;
        	<span class="error">#{error 'changeQuantityWay' /}</span>
        	<span class="error">#{error 'quantityLeft' /}</span>
        	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        	#{/field}
    	</p>
    	<br>
    	<p>
    		<input type="submit" value="保存修改" />
    		<input type="button" value="重置数据" onClick="reSetData()"/>
    		<input type="button" value="返回列表" onClick="goBack()"/>
    	</p>
	</fieldset>
	#{/form}
</div>